package com.sphd.beautysalon.model;


import com.android.volley.VolleyError;
import com.sphd.beautysalon.presenter.RegistPresenterImpl;
import com.sphd.beautysalon.interfaces.VolleyJsonObjectCallBack;

import org.json.JSONException;
import org.json.JSONObject;

/**
 * Created by Hu on 2016/10/27
 */

public class RegistModelImpl implements RegistModel, VolleyJsonObjectCallBack {
    RegistPresenterImpl registPresenter;
    @Override
    public void sendUrl(String url, RegistPresenterImpl registPresenter) {
        this.registPresenter=registPresenter;
        volleyUtil.setJsonObjectRequest(url,this);
    }


    @Override
    public void onResponse(JSONObject response) {
        try {
            int res= response.getInt("res");
            registPresenter.sendRes(res);
        } catch (JSONException e) {
            e.printStackTrace();
        }
    }

    @Override
    public void onErrorResponse(VolleyError error) {
            registPresenter.sendError(error);
    }
}